import React, { Component } from 'react'
import {withRouter} from 'react-router-dom'


class Header extends Component {
	render() {
		console.log('Header',this.props)
		return (
			<div className="row">
				<div className="col-xs-offset-2 col-xs-8">
					<div className="page-header">
						<h2>React Router Demo</h2>
						<button onClick={this.back}>←后退</button>
						<button onClick={this.forward}>前进→</button>
						<button onClick={this.testGo}>测试一下go</button>
					</div>
				</div>
			</div>
		)
	}

	back = ()=>{
		this.props.history.goBack()
		// console.log(this)
	}
	forward = ()=>{
		this.props.history.goForward()
	}
	testGo = ()=>{
		this.props.history.go(-2)
	}
}

export default withRouter(Header)

